class BookMailer < ActionMailer::Base
  def borrowbook(recipients,out_record)
    @subject    = '图书借阅通知'
#    @body["organizer"] = 
#    @body["options"] = subject.options
#    @body["url"] = url
    @body["reader"]=out_record.reader.reader_name
    @body["book_name"]=out_record.book.book_name
    @body["out_date"]=out_record.date
    @body["return_date"]=out_record.return_date
    @recipients = out_record.reader.email
    @from       = 'zhangyong@corp.leadtone.com'
    @sent_on    = Time.now
  end
  
  def returnbook(in_record,out_record)
    @subject = '图书归还通知'
    @body["reader"] = in_record.reader_name
    @body["book_name"]=in_record.book_name
    @body["out_date"]=in_record.out_date
    @body["return_date"]=in_record.in_date
    @body["isover"]=in_record.is_overtime
    @recipients = out_record.reader.email
    @from       = 'zhangyong@corp.leadtone.com'
    @sent_on    = Time.now
  end
  
  def reserveSuccess(order)
    @subject = '图书预约通知'
    @body["reader"] = order.reader.reader_name
    @body["book_name"]=order.book.book_name
    @body["created_at"]=order.created_at
    @recipients = order.reader.email
    @from       = 'zhangyong@corp.leadtone.com'
    @sent_on    = Time.now
  end
  
#  def reserveFailed(order)
#    @subject = '图书预约通知'
#    @body["reader"] = order.reader.reader_name
#    @body["book_name"]=order.book.book_name
#    @body["created_at"]=order.created_at
#    @recipients = order.reader.email
#    @from       = 'zhangyong@corp.leadtone.com'
#    @sent_on    = Time.now
#  end
end
